package flc.ast.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;

import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.adapter.ImitationAdapter;
import flc.ast.bean.MyDrawBean;
import flc.ast.databinding.ActivityImitationDrawBinding;
import stark.common.basic.event.EventStatProxy;

public class ImitationDrawActivity extends BaseAc<ActivityImitationDrawBinding> {

    public static boolean isImitation;
    private ImitationAdapter imitationAdapter;

    @Override
    protected int onCreate() {
        return R.layout.activity_imitation_draw;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(this, mDataBinding.event1Container);

        mDataBinding.ivImitationDrawBack.setOnClickListener(v -> onBackPressed());

        mDataBinding.rvImitationList.setLayoutManager(new GridLayoutManager(mContext, 2));
        imitationAdapter = new ImitationAdapter();
        mDataBinding.rvImitationList.setAdapter(imitationAdapter);
        imitationAdapter.setOnItemClickListener(this);
    }

    @Override
    protected void onItemClickCallback(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        NewDrawActivity.isNew = false;
        NewDrawActivity.drawBean = imitationAdapter.getItem(position);
        if (isImitation) {
            NewDrawActivity.isFill = false;
        } else {
            NewDrawActivity.isFill = true;
        }
        startActivity(NewDrawActivity.class);
    }

    @Override
    protected void initData() {
        if (isImitation) {
            getImitationData();
            mDataBinding.tvImitationTitle.setText(getString(R.string.imitation_draw));
        } else {
            getFunFillingData();
            mDataBinding.tvImitationTitle.setText(getString(R.string.fun_filling));
        }
    }

    private void getImitationData() {
        List<MyDrawBean> list = new ArrayList<>();
        list.add(new MyDrawBean(R.drawable.mm1, R.drawable.m1));
        list.add(new MyDrawBean(R.drawable.mm2, R.drawable.m2));
        list.add(new MyDrawBean(R.drawable.mm3, R.drawable.m3));
        list.add(new MyDrawBean(R.drawable.mm4, R.drawable.m4));
        list.add(new MyDrawBean(R.drawable.mm5, R.drawable.m5));
        list.add(new MyDrawBean(R.drawable.mm6, R.drawable.m6));
        list.add(new MyDrawBean(R.drawable.mm7, R.drawable.m7));
        list.add(new MyDrawBean(R.drawable.mm8, R.drawable.m8));
        imitationAdapter.setList(list);
    }

    private void getFunFillingData() {
        List<MyDrawBean> list = new ArrayList<>();
        list.add(new MyDrawBean(R.drawable.aa1, R.drawable.a1));
        list.add(new MyDrawBean(R.drawable.aa2, R.drawable.a2));
        list.add(new MyDrawBean(R.drawable.aa3, R.drawable.a3));
        list.add(new MyDrawBean(R.drawable.aa4, R.drawable.a4));
        list.add(new MyDrawBean(R.drawable.aa5, R.drawable.a5));
        list.add(new MyDrawBean(R.drawable.aa6, R.drawable.a6));
        list.add(new MyDrawBean(R.drawable.aa7, R.drawable.a7));
        list.add(new MyDrawBean(R.drawable.aa8, R.drawable.a8));
        imitationAdapter.setList(list);
    }

}